package com.heima.wemedia.controller.v1;

import com.heima.model.wemedia.dtos.NewsAuthDto;
import com.heima.model.common.dtos.ResponseResult;
import com.heima.model.wemedia.dtos.AdWmNewsDto;
import com.heima.model.wemedia.dtos.WmNewsDto;
import com.heima.model.wemedia.dtos.WmNewsPageReqDto;
import com.heima.wemedia.service.WmNewsService;
import com.heima.wemedia.service.impl.WmTaskServiceImpl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * @Description TODO
 * @Author bo.li
 * @Date 2022/11/10 10:53
 * @Version 1.0
 */
@RestController
@RequestMapping("/api/v1/news")
public class WmNewsController {

    @Autowired
    private WmNewsService newsService;

    @Autowired
    private WmTaskServiceImpl service;

    @PostMapping("/list")
    public ResponseResult list(@RequestBody WmNewsPageReqDto reqDto){

        return newsService.list(reqDto);
    }

    @PostMapping("/submit")
    public ResponseResult submit(@RequestBody WmNewsDto newsDto) {

        return newsService.submit(newsDto);
    }

    @GetMapping("/exec")
    public String test(){
        service.delayTaskExec();
        return "OK";
    }

    /**
     * 对要进行人工审核的文章的列表查询
     *
     * @param dto
     * @return
     */
    @PostMapping("/list_vo")
    public ResponseResult list_vo(@RequestBody AdWmNewsDto dto) {
        return newsService.list_vo(dto);
    }

    /**
     * 自媒体端自媒体文章人工审核的审核失败
     * @param dto
     * @return
     */
    @PostMapping("/auth_fail")
    public ResponseResult authFail(@RequestBody NewsAuthDto dto){
        return newsService.authFail(dto);
    }

    /**
     *
     * @param dto
     * @return
     */
    @PostMapping("/auth_pass")
    public ResponseResult authPass(@RequestBody NewsAuthDto dto){
        return newsService.authPass(dto);
    }



    @GetMapping("/one_vo/{id}")
    public ResponseResult one_vo(@PathVariable("id") int id){
        return newsService.one_vo(id);
    }

}